<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>class PowerAssert::Context - power_assert: Ruby Standard Library Documentation</title>


<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<script src="../js/jquery-3.2.0.min.js"></script>

<script src="../js/vue.min.js"></script>
<script src="../js/js.cookie.min.js"></script>

<link href="../css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="../css/rdoc.css" rel="stylesheet">
<link href="../css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
  var darkModeCsseHref = "../css/rdoc-dm.css"
  var defaultModeCssHref = "../css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="class">
  <!-- this is class.html -->

  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0.preview2 NOT FOUND -->
  </div> <!-- end action bar -->

  <div class='wrapper hdiv'>

    


    <nav id='vapp' role="navigation">
    <div id="project-navigation">
      <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="../index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

      <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

    </div>


    

    <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>
    <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
      <div id="class-metadata">
        
        
<div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  <p class="link">Object
</div>

        
        
        
<!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    <li ><a href="#method-c-new">::new</a>
    <li ><a href="#method-i-build_assertion_message">#build_assertion_message</a>
    <li ><a href="#method-i-column2display_offset">#column2display_offset</a>
    <li ><a href="#method-i-detect_path">#detect_path</a>
    <li ><a href="#method-i-encoding_safe_rstrip">#encoding_safe_rstrip</a>
    <li ><a href="#method-i-enum_count_by">#enum_count_by</a>
    <li ><a href="#method-i-find_all_identified_calls">#find_all_identified_calls</a>
    <li ><a href="#method-i-fired-3F">#fired?</a>
    <li ><a href="#method-i-message">#message</a>
    <li ><a href="#method-i-message_proc">#message_proc</a>
    <li ><a href="#method-i-uniq_calls">#uniq_calls</a>
  </ul>
</div>

      </div>
     </div>
    </nav>


    <div id='extraz'><div class='adzbox-index'  >
      
     </div>         
    </div>

    <main role="main" aria-labelledby="class-PowerAssert::Context">
    <h1 id="class-PowerAssert::Context" class="class">
      class PowerAssert::Context
    </h1>

    <section class="description">
    
    </section>

      <section id="5Buntitled-5D" class="documentation-section">


      <section class="constants-list">
      <header>
      <h3>Constants</h3>
      </header>
      <dl>
          <dt id="Value">Value
          <dd>
        </dl>
        </section>



                <section id="public-class-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Class Methods</h3>
                </header>

                  <div id="method-c-new" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">new</span><span
                                class="method-args">(base_caller_length)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 10</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">base_caller_length</span>)
  <span class="ruby-ivar">@fired</span> = <span class="ruby-keyword">false</span>
  <span class="ruby-ivar">@target_thread</span> = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>
  <span class="ruby-identifier">method_id_set</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-ivar">@return_values</span> = []
  <span class="ruby-ivar">@trace_return</span> = <span class="ruby-constant">TracePoint</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:return</span>, <span class="ruby-value">:c_return</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">tp</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">method_id_set</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@target_thread</span>
      <span class="ruby-identifier">method_id_set</span> = <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">method_id_set</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">method_id</span> = <span class="ruby-identifier">tp</span>.<span class="ruby-identifier">callee_id</span>
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span> <span class="ruby-identifier">method_id_set</span>[<span class="ruby-identifier">method_id</span>]
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">tp</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:c_return</span> <span class="ruby-keyword">and</span>
            <span class="ruby-keyword">not</span> (<span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">lineno</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">tp</span>.<span class="ruby-identifier">lineno</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">tp</span>.<span class="ruby-identifier">path</span>)
    <span class="ruby-identifier">locs</span> = <span class="ruby-constant">PowerAssert</span>.<span class="ruby-identifier">app_caller_locations</span>
    <span class="ruby-identifier">diff</span> = <span class="ruby-identifier">locs</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">base_caller_length</span>
    <span class="ruby-keyword">if</span> (<span class="ruby-identifier">tp</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:c_return</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">diff</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">tp</span>.<span class="ruby-identifier">event</span> <span class="ruby-operator">==</span> <span class="ruby-value">:return</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">diff</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">2</span>) <span class="ruby-keyword">and</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@target_thread</span>
      <span class="ruby-identifier">idx</span> = <span class="ruby-operator">-</span>(<span class="ruby-identifier">base_caller_length</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>)
      <span class="ruby-keyword">if</span> <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">locs</span>[<span class="ruby-identifier">idx</span>].<span class="ruby-identifier">path</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@parser</span>.<span class="ruby-identifier">lineno</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">locs</span>[<span class="ruby-identifier">idx</span>].<span class="ruby-identifier">lineno</span>
        <span class="ruby-identifier">val</span> = <span class="ruby-constant">PowerAssert</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">lazy_inspection</span> <span class="ruby-operator">?</span>
          <span class="ruby-identifier">tp</span>.<span class="ruby-identifier">return_value</span> <span class="ruby-operator">:</span>
          <span class="ruby-constant">InspectedValue</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">SafeInspectable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">tp</span>.<span class="ruby-identifier">return_value</span>).<span class="ruby-identifier">inspect</span>)
        <span class="ruby-ivar">@return_values</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Value</span>[<span class="ruby-identifier">method_id</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">val</span>, <span class="ruby-identifier">locs</span>[<span class="ruby-identifier">idx</span>].<span class="ruby-identifier">lineno</span>, <span class="ruby-keyword">nil</span>]
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">rescue</span> <span class="ruby-constant">Exception</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">e</span>
    <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;power_assert: [BUG] Failed to trace: #{e.class}: #{e.message}&quot;</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:full_message</span>)
      <span class="ruby-identifier">warn</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">full_message</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/^/</span>, <span class="ruby-string">&#39;power_assert:     &#39;</span>)
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Public Instance Methods</h3>
                </header>

                  <div id="method-i-message" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">message</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="message-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 43</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">message</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-string">&#39;call #yield or #enable at first&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">fired?</span>
  <span class="ruby-ivar">@message</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">build_assertion_message</span>(<span class="ruby-ivar">@parser</span>, <span class="ruby-ivar">@return_values</span>).<span class="ruby-identifier">freeze</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-message_proc" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">message_proc</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="message_proc-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 48</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">message_proc</span>
  <span class="ruby-operator">-&gt;</span> { <span class="ruby-identifier">message</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

                <section id="private-instance-5Buntitled-5D-method-details" class="method-section">
                <header>
                <h3>Private Instance Methods</h3>
                </header>

                  <div id="method-i-build_assertion_message" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">build_assertion_message</span><span
                                class="method-args">(parser, return_values)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="build_assertion_message-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 58</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">build_assertion_message</span>(<span class="ruby-identifier">parser</span>, <span class="ruby-identifier">return_values</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-constant">PowerAssert</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">colorize_message</span>
    <span class="ruby-identifier">line</span> = <span class="ruby-constant">IRB</span><span class="ruby-operator">::</span><span class="ruby-constant">Color</span>.<span class="ruby-identifier">colorize_code</span>(<span class="ruby-identifier">parser</span>.<span class="ruby-identifier">line</span>, <span class="ruby-value">ignore_error:</span> <span class="ruby-keyword">true</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">line</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">line</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">path</span> = <span class="ruby-identifier">detect_path</span>(<span class="ruby-identifier">parser</span>, <span class="ruby-identifier">return_values</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">line</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">path</span>

  <span class="ruby-identifier">c2d</span> = <span class="ruby-identifier">column2display_offset</span>(<span class="ruby-identifier">parser</span>.<span class="ruby-identifier">line</span>)
  <span class="ruby-identifier">return_values</span>, <span class="ruby-identifier">methods_in_path</span> = <span class="ruby-identifier">find_all_identified_calls</span>(<span class="ruby-identifier">return_values</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">return_values</span>.<span class="ruby-identifier">zip</span>(<span class="ruby-identifier">methods_in_path</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span>, <span class="ruby-identifier">j</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">unless</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">name</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">j</span>.<span class="ruby-identifier">name</span>
      <span class="ruby-identifier">warn</span> <span class="ruby-node">&quot;power_assert: [BUG] Failed to get column: #{i.name}&quot;</span>
      <span class="ruby-keyword">return</span> <span class="ruby-identifier">line</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">i</span>.<span class="ruby-identifier">display_offset</span> = <span class="ruby-identifier">c2d</span>[<span class="ruby-identifier">j</span>.<span class="ruby-identifier">column</span>]
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">refs_in_path</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:ref</span> }
  <span class="ruby-identifier">ref_values</span> = <span class="ruby-identifier">refs_in_path</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-constant">Value</span>[<span class="ruby-identifier">i</span>.<span class="ruby-identifier">name</span>, <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">binding</span>.<span class="ruby-identifier">eval</span>(<span class="ruby-identifier">i</span>.<span class="ruby-identifier">name</span>), <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">lineno</span>, <span class="ruby-identifier">i</span>.<span class="ruby-identifier">column</span>, <span class="ruby-identifier">c2d</span>[<span class="ruby-identifier">i</span>.<span class="ruby-identifier">column</span>]] }
  <span class="ruby-identifier">vals</span> = (<span class="ruby-identifier">return_values</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">ref_values</span>).<span class="ruby-identifier">find_all</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:display_offset</span>).<span class="ruby-identifier">sort_by</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:display_offset</span>).<span class="ruby-identifier">reverse</span>
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">line</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">fmt</span> = (<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-identifier">vals</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">display_offset</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">if</span> <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">display_offset</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">i</span> }
      <span class="ruby-node">&quot;%&lt;#{i}&gt;s&quot;</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-identifier">line</span>[<span class="ruby-identifier">i</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&quot;\t&quot;</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;\t&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39; &#39;</span>
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>.<span class="ruby-identifier">join</span>
  <span class="ruby-identifier">lines</span> = []
  <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>
  <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">sprintf</span>(<span class="ruby-identifier">fmt</span>, <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">each_with_object</span>({}) {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span>, <span class="ruby-identifier">h</span><span class="ruby-operator">|</span> <span class="ruby-identifier">h</span>[<span class="ruby-value">:&quot;#{v.display_offset}&quot;</span>] = <span class="ruby-string">&#39;|&#39;</span> }).<span class="ruby-identifier">chomp</span>
  <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">inspected_val</span> = <span class="ruby-constant">SafeInspectable</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Inspector</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">i</span>.<span class="ruby-identifier">value</span>, <span class="ruby-identifier">i</span>.<span class="ruby-identifier">display_offset</span>)).<span class="ruby-identifier">inspect</span>
    <span class="ruby-identifier">inspected_val</span>.<span class="ruby-identifier">each_line</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">l</span><span class="ruby-operator">|</span>
      <span class="ruby-identifier">map_to</span> = <span class="ruby-identifier">vals</span>.<span class="ruby-identifier">each_with_object</span>({}) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">j</span>, <span class="ruby-identifier">h</span><span class="ruby-operator">|</span>
        <span class="ruby-identifier">h</span>[<span class="ruby-value">:&quot;#{j.display_offset}&quot;</span>] = [<span class="ruby-identifier">l</span>, <span class="ruby-string">&#39;|&#39;</span>, <span class="ruby-string">&#39; &#39;</span>][<span class="ruby-identifier">i</span>.<span class="ruby-identifier">display_offset</span> <span class="ruby-operator">&lt;=&gt;</span> <span class="ruby-identifier">j</span>.<span class="ruby-identifier">display_offset</span>]
      <span class="ruby-keyword">end</span>
      <span class="ruby-identifier">lines</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">encoding_safe_rstrip</span>(<span class="ruby-identifier">sprintf</span>(<span class="ruby-identifier">fmt</span>, <span class="ruby-identifier">map_to</span>))
    <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&quot;\n&quot;</span>)
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-column2display_offset" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">column2display_offset</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="column2display_offset-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 149</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">column2display_offset</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-identifier">display_offset</span> = <span class="ruby-value">0</span>
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">each_char</span>.<span class="ruby-identifier">with_object</span>([]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">c</span>, <span class="ruby-identifier">r</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">c</span>.<span class="ruby-identifier">bytesize</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span>
      <span class="ruby-identifier">r</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">display_offset</span>
    <span class="ruby-keyword">end</span>
    <span class="ruby-identifier">display_offset</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">ascii_only?</span> <span class="ruby-operator">?</span> <span class="ruby-value">1</span> <span class="ruby-operator">:</span> <span class="ruby-value">2</span> <span class="ruby-comment"># FIXME</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-detect_path" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">detect_path</span><span
                                class="method-args">(parser, return_values)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="detect_path-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 104</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">detect_path</span>(<span class="ruby-identifier">parser</span>, <span class="ruby-identifier">return_values</span>)
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">call_paths</span>.<span class="ruby-identifier">flatten</span>.<span class="ruby-identifier">uniq</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">method_id_set</span>.<span class="ruby-identifier">empty?</span>
  <span class="ruby-identifier">all_paths</span> = <span class="ruby-identifier">parser</span>.<span class="ruby-identifier">call_paths</span>
  <span class="ruby-identifier">return_value_names</span> = <span class="ruby-identifier">return_values</span>.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>)
  <span class="ruby-identifier">uniq_calls</span> = <span class="ruby-identifier">uniq_calls</span>(<span class="ruby-identifier">all_paths</span>)
  <span class="ruby-identifier">uniq_call</span> = <span class="ruby-identifier">return_value_names</span>.<span class="ruby-identifier">find</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">uniq_calls</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">i</span>) }
  <span class="ruby-identifier">detected_paths</span> = <span class="ruby-identifier">all_paths</span>.<span class="ruby-identifier">find_all</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">method_names</span> = <span class="ruby-identifier">path</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ident</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ident</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:method</span> }.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>)
    <span class="ruby-keyword">break</span> [<span class="ruby-identifier">path</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">uniq_call</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">method_names</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">uniq_call</span>)
    <span class="ruby-identifier">return_value_names</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">method_names</span>
  <span class="ruby-keyword">end</span>
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">detected_paths</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
  <span class="ruby-identifier">detected_paths</span>[<span class="ruby-value">0</span>]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-encoding_safe_rstrip" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">encoding_safe_rstrip</span><span
                                class="method-args">(str)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="encoding_safe_rstrip-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 138</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">encoding_safe_rstrip</span>(<span class="ruby-identifier">str</span>)
  <span class="ruby-identifier">str</span>.<span class="ruby-identifier">rstrip</span>
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-constant">Encoding</span><span class="ruby-operator">::</span><span class="ruby-constant">CompatibilityError</span>
  <span class="ruby-identifier">enc</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">encoding</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">enc</span>.<span class="ruby-identifier">ascii_compatible?</span>
    <span class="ruby-identifier">str</span>.<span class="ruby-identifier">b</span>.<span class="ruby-identifier">rstrip</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-identifier">enc</span>)
  <span class="ruby-keyword">else</span>
    <span class="ruby-identifier">str</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-enum_count_by" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">enum_count_by</span><span
                                class="method-args">(enum, &amp;blk)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="enum_count_by-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 134</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">enum_count_by</span>(<span class="ruby-identifier">enum</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>)
  <span class="ruby-constant">Hash</span>[<span class="ruby-identifier">enum</span>.<span class="ruby-identifier">group_by</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">blk</span>).<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> [<span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>.<span class="ruby-identifier">length</span>] }]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-find_all_identified_calls" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">find_all_identified_calls</span><span
                                class="method-args">(return_values, path)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="find_all_identified_calls-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 124</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find_all_identified_calls</span>(<span class="ruby-identifier">return_values</span>, <span class="ruby-identifier">path</span>)
  <span class="ruby-identifier">return_value_num_of_calls</span> = <span class="ruby-identifier">enum_count_by</span>(<span class="ruby-identifier">return_values</span>, <span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>)
  <span class="ruby-identifier">path_num_of_calls</span> = <span class="ruby-identifier">enum_count_by</span>(<span class="ruby-identifier">path</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ident</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ident</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:method</span> }, <span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>)
  <span class="ruby-identifier">identified_calls</span> = <span class="ruby-identifier">return_value_num_of_calls</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">num</span><span class="ruby-operator">|</span> <span class="ruby-identifier">path_num_of_calls</span>[<span class="ruby-identifier">name</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">num</span> }.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:first</span>)
  [
    <span class="ruby-identifier">return_values</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">val</span><span class="ruby-operator">|</span> <span class="ruby-identifier">identified_calls</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">val</span>.<span class="ruby-identifier">name</span>) },
    <span class="ruby-identifier">path</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ident</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ident</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:method</span> <span class="ruby-keyword">and</span> <span class="ruby-identifier">identified_calls</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">ident</span>.<span class="ruby-identifier">name</span>)  }
  ]
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-fired-3F" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">fired?</span><span
                                class="method-args">()</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="fired-3F-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 54</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fired?</span>
  <span class="ruby-ivar">@fired</span>
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                  <div id="method-i-uniq_calls" class="method-detail ">
                            <div class="method-heading">
                              <span class="method-name">uniq_calls</span><span
                                class="method-args">(paths)</span>
                              <span class="method-click-advice">click to toggle source</span>
                            </div>

                            <div class="method-description">
                              

                              <div class="method-source-code" id="uniq_calls-source">
            <pre><span class="ruby-comment"># File power_assert-2.0.3/lib/power_assert/context.rb, line 119</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">uniq_calls</span>(<span class="ruby-identifier">paths</span>)
  <span class="ruby-identifier">all_calls</span> = <span class="ruby-identifier">enum_count_by</span>(<span class="ruby-identifier">paths</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">path</span><span class="ruby-operator">|</span> <span class="ruby-identifier">path</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">ident</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ident</span>.<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:method</span> }.<span class="ruby-identifier">map</span>(<span class="ruby-operator">&amp;</span><span class="ruby-value">:name</span>).<span class="ruby-identifier">uniq</span> }.<span class="ruby-identifier">flatten</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span> }
  <span class="ruby-identifier">all_calls</span>.<span class="ruby-identifier">find_all</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">_</span>, <span class="ruby-identifier">call_count</span><span class="ruby-operator">|</span> <span class="ruby-identifier">call_count</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span> }.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">name</span>, <span class="ruby-identifier">_</span><span class="ruby-operator">|</span> <span class="ruby-identifier">name</span> }
<span class="ruby-keyword">end</span></pre>
                              </div>
                            </div>


                          </div>

                          </section>

              </section>
              </main>



            </div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

